package groundTruthTest;

import gate.util.GateException;

import java.net.MalformedURLException;
import java.util.List;

import domain.EclapRecord;
import domain.NameRawRecord;

import persistence.Axdbv4HibernateManager;
import textEngine.NameFinder;

/*
 * Classe che testa il funzionamento di Annie per l'individuazione 
 * dei nomi di persona 
 */

public class GroundTruth_NameFinder_Tester {
	
	private String[] axoidGroundTruth={"urn:axmedis:00000:obj:59f95b7b-e403-4cd4-87d5-f943c773d504",
			"urn:axmedis:00000:obj:cd2e1566-bd0a-4196-9e2d-63c0bccaee1d",
			"urn:axmedis:00000:obj:b04522c1-ac86-4e7c-908d-b35faada3cd6",
			"urn:axmedis:00000:obj:43314292-3f8b-484f-944a-65226e651ccc",
			"urn:axmedis:00000:obj:38bdea51-1bce-4cb9-85a8-71e35eadcc6f",
			"urn:axmedis:00000:obj:ac722ed5-7705-48b9-87a4-f161f19c44f0",
			"urn:axmedis:00000:obj:d81d7bd8-e2df-496b-86dc-d56bad2865d3",
			"urn:axmedis:00000:obj:050aa1c5-ad6c-4054-a6fa-fc832507bec7",
			"urn:axmedis:00000:obj:ebd4eb2e-adb1-41f3-8d88-4f9022baa240",
			"urn:axmedis:00000:obj:a6e0fb48-c81f-4242-812c-cdae57bfa31a",
			"urn:axmedis:00000:obj:00003906-cd3e-483d-a28f-efd056ee63bf",
			"urn:axmedis:00000:obj:0000492c-b65a-4291-bb21-c3b39b33e345"};
	
	private void testAnnie(String tableName) throws MalformedURLException, GateException{
		System.out.println("**Funzione di test** Presi gli axoid di groundTruth e specificata la tabella dcmi/optionalField esegue la funzione NameFinder implementata con ANNIE" +
				"\n\tPer ogni oggetto (specificato dall'axoid) fa valutare tutti i suoi campi al nameFinderANNIE e riporta i nomi trovati");
		Axdbv4HibernateManager dbManager= Axdbv4HibernateManager.getIstance();
		NameFinder nf= new NameFinder();
		//per ogni oggetto specificato da 'axoid' prende tutti i campi presenti nella tabella 
		for (String axoid : axoidGroundTruth) {
			System.out.println("Elaboro axoid="+axoid);
			List<EclapRecord> records=dbManager.getRecordsByAxoid(axoid, tableName);
			List<NameRawRecord> nameRawRecordList=nf.findNames(records);
			for (NameRawRecord nameRawRecord : nameRawRecordList) {
				System.out.println("\t"+nameRawRecord.getField()+": "+nameRawRecord.getValue());
			}
		}
	}
	public static void main(String[] args) throws MalformedURLException, GateException {
		new GroundTruth_NameFinder_Tester().testAnnie(EclapRecord.typeOptionalField);
	}
}
